// 把登录封装成自定义组合式函数   --- react里面的自定义hooks
// 函数名称必须以use开头
import { useQuery } from '@tanstack/vue-query';
import type { User } from '../types/user';
import { Login } from '../request/api';

export function useLogin (userGetter:()=>User){
    return useQuery({
        queryKey:['userLogin', userGetter()], //加入formData作为key, 强制缓存时效
        queryFn: async()=>{ const data = await Login(userGetter());return data },
        enabled: false, // refetch 函数，接口执行
    })
}